<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            margin: 0;
        }
        .box {
            height: 100px;
            width: 100px;
            background-color: red;
            /* position: absolute;
            left: 0;
            top: 0; */
            transform: translate(0, 0);
        }
    </style>
</head>
<body>
    <div class="box"></div>

    <script>
        let left = 0;
        const box = document.querySelector('.box');
        setInterval(() => {
            // 重排
            // box.setAttribute('style', `left: ${ ++left }px`);
            // 重绘
            box.setAttribute('style', `transform: translate(${ ++left }px, 0)`);
        }, 20);
    </script>
</body>
</html>